{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {},
   "outputs": [],
   "source": [
    "\n",
    "from os.path import join, split, exists,isfile\n",
    "import os \n",
    "import shutil\n",
    "\n",
    "from tqdm import  tqdm\n",
    "class Checker:\n",
    "\n",
    "    def __init__(self,root ):\n",
    "        self.root = root \n",
    "\n",
    "        self.dirs = os.listdir(root)\n",
    "        suffix = \"_vh_clean_2.labels.ply\"\n",
    "        extra_dir = \"/home/DISCOVER_summer2022/xusc//exp/data/scannet/script_for_download/download20231016/scans\"\n",
    "        \n",
    "        extra_dir_list = os.listdir(extra_dir)\n",
    "        \n",
    "\n",
    "        self.data = {name:os.listdir(join(root,name)) for name in self.dirs}\n",
    "\n",
    "        #* all data, including test set \n",
    "        # for dirn in tqdm(self.dirs):\n",
    "        for dirn in tqdm(extra_dir_list):\n",
    "            \n",
    "            \n",
    "            src_file = join(extra_dir,dirn,dirn+suffix)\n",
    "            target_dir = join(root,dirn)\n",
    "            if exists(join(target_dir,dirn+suffix)):\n",
    "                continue\n",
    "\n",
    "            if exists(src_file) and exists(target_dir):\n",
    "                # print('cp %s to %s'%(src_file,target_dir))\n",
    "                shutil.copy(src_file,target_dir)\n",
    "            else:\n",
    "                print('%s is wrong \\n or  %s is wrong '%(src_file,target_dir))\n",
    "           \n",
    "           \n",
    "                raise Exception\n",
    "            \n",
    "\n",
    "            \n",
    "\n",
    "\n",
    "    def __len__(self):\n",
    "        return len(self.dirs)\n",
    "    \n",
    "    def getname(self,idx):\n",
    "        return self.dirs[idx]\n",
    "\n",
    "\n",
    "    def getitem(self,idx):\n",
    "\n",
    "        return self.data[self.dirs[idx]]\n",
    "\n",
    "\n",
    "        \n",
    "root = \"/home/DISCOVER_summer2022/xusc/exp/co-t3-dref/refering_codes/MVT-3DVG/data/scans\"\n",
    "# checker = Checker(root)\n",
    "\n",
    "\n",
    "\n",
    "# not_dirs=  []\n",
    "# for idx in range(checker.__len__()):\n",
    "#     flag = False\n",
    "#     all_files  = checker.getitem(idx)\n",
    "#     for name in all_files:\n",
    "#         if suffix in name:\n",
    "#             flag = True\n",
    "#             break\n",
    "#     if not flag:\n",
    "#         not_dirs.append(checker.getname(idx))\n",
    "        \n",
    "\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "1513"
      ]
     },
     "execution_count": 29,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# len(not_dirs)\n",
    "\n",
    "\n",
    "extra_dir = \"/home/DISCOVER_summer2022/xusc//exp/data/scannet/script_for_download/download20231016/scans\"\n",
    "\n",
    "\n",
    "\n",
    "import numpy as np \n",
    "\n",
    "# np.savetxt('scannet_train_list.txt',os.listdir(extra_dir),fmt='%s')\n",
    "len(np.loadtxt('scannet_train_list.txt',dtype=np.str0).tolist())\n",
    "\n",
    "# os.getcwd()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {},
   "outputs": [],
   "source": [
    "import sys \n",
    "import os.path as osp\n",
    "sys.path.insert(0,'/home/DISCOVER_summer2022/xusc/exp/co-t3-dref/refering_codes/MVT-3DVG')\n",
    "from referit3d.utils import immediate_subdirectories, create_dir, pickle_data, str2bool\n",
    "origin  = '/home/DISCOVER_summer2022/xusc/exp/co-t3-dref/refering_codes/MVT-3DVG/data/scans'\n",
    "\n",
    "a  = [osp.basename(i) for i in immediate_subdirectories(extra_dir)]\n",
    "b  = [osp.basename(i) for i in immediate_subdirectories(origin)]\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(1513, 1613)"
      ]
     },
     "execution_count": 22,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "len(a),len(b)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "cerberus2",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.13"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
